import 'package:flutter/material.dart';

class MyTab extends StatefulWidget {
  const MyTab({Key? key, required this.tabsInfo}) : super(key: key);
  final List tabsInfo;

  @override
  _MyTabState createState() => _MyTabState();
}

class _MyTabState extends State<MyTab> with SingleTickerProviderStateMixin {
  late TabController _tabController;
  late int _currentIndex;
  @override
  void initState() {
    _currentIndex = 0;
    _tabController = TabController(length: 2, vsync: this);
    super.initState();
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        bottom: TabBar(
          controller: _tabController,
          tabs: widget.tabsInfo.map((item){
            return Text(item['name']);
          }).toList(),
        ),
      ),
      body: TabBarView(
        controller: _tabController,
        children: widget.tabsInfo.map((item){
          return Text(item['name']);
        }).toList(),
      ),
    );
  }
}
